package com.banciyuan.bcywebview.biz.detail.comment;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.banciyuan.bcywebview.R;

import java.util.List;

import de.greenrobot.daoexample.model.DetailComment;
import de.greenrobot.daoexample.model.DetailType;


public class DetailCommentAdapter extends BaseAdapter {
    private Context mContext;
    private List<DetailComment> mCommentList;
    private LayoutInflater mLayoutInflater;
    private DetailType mDetailType;
    private String mCommentId;
    private String mWorkAuthorUid;
    private String mCommentAuthorUid;

    public DetailCommentAdapter(Context context, List<DetailComment> commentList, DetailType detailType, String commentId, String workAuthorUid, String commentAuthorUid) {
        mContext = context;
        mLayoutInflater = LayoutInflater.from(mContext);
        mCommentList = commentList;
        mDetailType = detailType;
        mCommentId = commentId;
        mWorkAuthorUid = workAuthorUid;
        mCommentAuthorUid = commentAuthorUid;
    }

    @Override
    public int getCount() {
        return mCommentList.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        DetailCommentHolder comment;
        if (null == convertView) {
            convertView = mLayoutInflater.inflate(R.layout.comment_detail_item, parent, false);
            comment = new DetailCommentHolder(convertView, mCommentId, mWorkAuthorUid, mCommentAuthorUid);
            convertView.setTag(comment);
        } else {
            comment = (DetailCommentHolder) convertView.getTag();
        }
        comment.setData(position, mCommentList.get(position), mContext, true, mDetailType, true);
        return convertView;
    }
}
